<template>
    <div id="cc">
        <!--        <div style="position: sticky;top:0;z-index: 9999;background: #fff;">-->
        <!--            <div style="display: flex;flex-direction: row;height: 40px;">-->
        <!--                <div-->
        <!--                        style="display: flex;justify-content: center;align-items: center;width: 33.33vw;-->
        <!--                        font-family: PingFangSC-Regular;font-size: 14px;"-->
        <!--                        :style="{borderBottom:activeStep==index?'2px solid #454592':'1px solid #ddd',color:activeStep==index?'#454592':'#333'}"-->
        <!--                        v-for="(item,index) in ['基本','既往治疗','本次治疗']"-->
        <!--                        @click="privilegeHeadClick('anchor-'+index)">-->
        <!--                    <span>-->
        <!--                      {{item}}-->
        <!--                    </span>-->
        <!--                </div>-->
        <!--            </div>-->
        <!--        </div>-->
        <Tabs scrollspy sticky color="#454592">
            <div class="wrapper" id="section">
                <Tab title="基本">
                    <!--基本信息-->
                    <div id="anchor-0" class="privilege-wrap">
                        <!--标题-->
                        <div class="title">
                            <div class="title_block"></div>
                            <div class="title_text">
                                基本信息
                            </div>
                        </div>
                        <!--field-->

                        <div class="field_item">
                            <div class="field_title">
                                性别
                            </div>
                            <div>
                                <Cell is-link :title="form.tabBasic.B03" @click="genderShow=true"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                就诊地点
                            </div>
                            <div>
                                <Cell is-link :title="form.tabBasic.B01" @click="locationShow=true"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                年龄
                            </div>
                            <div>
                                <Cell is-link :title="form.tabBasic.B02" @click="B02Show=true"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                糖尿病病程（年）
                            </div>
                            <div>
                                <Cell is-link :title="form.tabBasic.B06" @click="diseaseyearShow=true"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                合并症(可多选)
                            </div>
                            <div>
                                <Cell is-link :title="form.tabBasic.C15.join(',')" @click="diseaseHistoryShow=true"/>
                            </div>
                        </div>

                        <Overlay :show="B02Show">
                            <RadioList :fullList="B02Options" :checked="form.tabBasic.B02" @confirm="B02Confirm"
                                       @cancel="B02Show=false"/>
                        </Overlay>
                        <Overlay :show="genderShow">
                            <RadioList :fullList="genderOptions" :checked="form.tabBasic.B03" @confirm="genderConfirm"
                                       @cancel="genderShow=false"/>
                        </Overlay>
                        <Overlay :show="locationShow">
                            <RadioList :fullList="locationOptions" :checked="form.tabBasic.B01"
                                       @confirm="locationConfirm"
                                       @cancel="locationShow=false"/>
                        </Overlay>
                        <Overlay :show="diseaseyearShow">
                            <RadioList :fullList="diseaseyearOptions" :checked="form.tabBasic.B06"
                                       @confirm="diseaseyearConfirm"
                                       @cancel="diseaseyearShow=false"/>
                        </Overlay>
                        <Overlay :show="diseaseHistoryShow">
                            <CheckboxList1 :fullList="diseaseHistoryOptions" :checked="form.tabBasic.C15"
                                           @confirm="diseaseHistoryconfirm" @cancel="diseaseHistoryShow = false"/>
                        </Overlay>
                    </div>
                    <!--基本信息-->
                </Tab>
                <Tab title="既往治疗">
                    <!--疾病信息-->
                    <div class="mt20 privilege-wrap" id="anchor-1">
                        <!--标题-->
                        <div class="title">
                            <div class="title_block"></div>
                            <div class="title_text">
                                既往治疗方案
                            </div>
                        </div>
                        <!--field-->
                        <div class="field_item">
                            <div class="field_title">
                                既往使用过的方案（可多选）
                            </div>
                            <div>
                                <Cell is-link :title="form.tabDisease.T09.join(',')" @click="lastplanShow=true"/>
                            </div>
                        </div>
                        <div class="title_sub">
                            转换方案前最后一次检查情况
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                体重(kg)
                            </div>
                            <div>
                                <Field v-model="form.tabDisease.B04" type="number" @blur="B04Change"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                身高(cm)
                            </div>
                            <div>
                                <Field v-model="form.tabDisease.B07" type="number" @blur="B07Change"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                BMI(kg/m²)
                            </div>
                            <div>
                                <Field v-model="form.tabDisease.B05" type="number"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                糖化血红蛋白（%）
                            </div>
                            <div>
                                <Field v-model="form.tabDisease.D03" type="number" placeholder="未检测"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                空腹血糖（mmol/L）
                            </div>
                            <div>
                                <Field v-model="form.tabDisease.D01" type="number" placeholder="未检测"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                餐后血糖（mmol/L）
                            </div>
                            <div>
                                <Field v-model="form.tabDisease.D02" type="number" placeholder="未检测"/>
                            </div>
                        </div>

                        <div class="field_item">
                            <div class="field_title">
                                空腹C肽
                            </div>
                            <div style="width: 100%;display: flex;border-bottom: 1px solid #ddd">
                                <div style="width: 70%;float: left">
                                    <Field v-model="form.tabDisease.D43" type="number"
                                           style="border-bottom: 1px solid #fff"
                                           placeholder="未检测"/>
                                </div>
                                <div style="display: flex" v-model="form.tabDisease.D44">
                                    <div :class="form.tabDisease.D44 == '(ug/ml)'?'capsule1_1':'capsule1'"
                                         @click="form.tabDisease.D44 = '(ug/ml)'"><span>(ug/ml)</span></div>
                                    <div :class="form.tabDisease.D44 == '(nmol/L)'?'capsule2_1':'capsule2'"
                                         @click="form.tabDisease.D44 = '(nmol/L)'"><span>(nmol/L)</span></div>
                                </div>
                            </div>
                        </div>
                        <Overlay :show="lastplanShow">
                            <CheckboxList2 :fullList="lastplanOptions" :checked="form.tabDisease.T09"
                                          @confirm="lastplanConfirm" @cancel="lastplanShow = false"/>
                        </Overlay>
                    </div>
                    <!--疾病信息-->
                </Tab>
                <Tab title="本次治疗">
                    <!--合并症信息-->
                    <div class="mt20 privilege-wrap" id="anchor-2">
                        <!--标题-->
                        <div class="title">
                            <div class="title_block"></div>
                            <div class="title_text">
                                本次治疗信息
                            </div>
                        </div>
                        <!--field-->
                        <div class="title_sub">
                            空腹血糖（FPGmmol/L）
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                血糖目标
                            </div>
                            <div>
                                <Cell is-link :title="form.tabComplication.C16" @click="C16Show=true"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                当前血糖
                            </div>
                            <div>
                                <Field v-model="form.tabComplication.C17" type="number" @blur="C17Change"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                是否达标
                            </div>
                            <div>
                                <Field v-model="form.tabComplication.C18"/>
                            </div>
                        </div>

                        <div class="title_sub">
                            餐后血糖（PPGmmol/L）
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                血糖目标
                            </div>
                            <div>
                                <Cell is-link :title="form.tabComplication.C19" @click="C19Show=true"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                当前血糖
                            </div>
                            <div>
                                <Field v-model="form.tabComplication.C20" type="number" @blur="C20Change"/>
                            </div>
                        </div>
                        <div class="field_item">
                            <div class="field_title">
                                是否达标
                            </div>
                            <div>
                                <Field v-model="form.tabComplication.C21"/>
                            </div>
                        </div>
                        <Overlay :show="C16Show">
                            <RadioList :fullList="C16Options" :checked="form.tabComplication.C16" @confirm="C16Confirm"
                                       @cancel="C16Show=false"/>
                        </Overlay>
                        <Overlay :show="C19Show">
                            <RadioList :fullList="C19Options" :checked="form.tabComplication.C19" @confirm="C19Confirm"
                                       @cancel="C19Show=false"/>
                        </Overlay>
                    </div>
                    <!--合并症信息-->
                    <!--治疗信息-->
                    <div class="mt20">
                        <!--标题-->
                        <div class="title_sub">
                            本次治疗方案
                        </div>
                        <!--field-->
                        <div class="field_item">
                            <div class="field_title">
                                选择方案（可多选）
                            </div>
                            <div>
                                <Cell is-link :title="form.treatment.T09.join(',')" @click="T09Show=true"/>
                            </div>
                        </div>
                        <div v-if="form.treatment.T09.includes('OADs')">
                            <div class="title_sub">
                                OADs
                            </div>
                            <div class="field_item">
                                <div class="field_title">
                                    口服药种数
                                </div>
                                <div>
                                    <Cell is-link :title="form.treatment.T18"
                                          @click="T18Show=true"/>
                                </div>
                            </div>
                        </div>
                        <div v-if="form.treatment.T09.includes('基础胰岛素')">
                            <div class="title_sub">
                                基础胰岛素
                            </div>
                            <div class="field_item" style="display: flex">
                                <div style="width: 100%;margin: 0 auto" v-model="form.treatment.T23">
                                    <div :class="form.treatment.T23 == '来得时'?'field_item1_1':'field_item1'"
                                         @click="form.treatment.T23='来得时'">来得时
                                    </div>
                                    <div :class="form.treatment.T23 == '其他胰岛素'?'field_item2_1':'field_item2'"
                                         @click="form.treatment.T23='其他胰岛素'">其他胰岛素
                                    </div>
                                    <div :class="form.treatment.T23 == '无'?'field_item3_1':'field_item3'"
                                         @click="form.treatment.T23='无'">无
                                    </div>
                                </div>
                            </div>
                            <div v-if="form.treatment.T23 == '来得时'">
                                <div class="field_item">
                                    <div class="field_title">
                                        使用天数
                                    </div>
                                    <div>
                                        <Cell is-link :title="form.treatment.T20"
                                              @click="T20Show=true"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        起始剂量（IU）
                                    </div>
                                    <div>
                                        <Field v-model="form.treatment.T21" type="number"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        目前剂量（IU）
                                    </div>
                                    <div>
                                        <Field v-model="form.treatment.T22" type="number"/>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div v-if="form.treatment.T09.includes('餐时胰岛素')">
                            <div class="title_sub">
                                餐时胰岛素
                            </div>
                            <div class="field_item" style="display: flex">
                                <div style="width: 100%;margin: 0 auto" v-model="form.treatment.T24">
                                    <div :class="form.treatment.T24 == '艾倍得'?'field_item1_1':'field_item1'"
                                         @click="form.treatment.T24='艾倍得'">艾倍得
                                    </div>
                                    <div :class="form.treatment.T24 == '其他胰岛素'?'field_item2_1':'field_item2'"
                                         @click="form.treatment.T24='其他胰岛素'">其他胰岛素
                                    </div>
                                    <div :class="form.treatment.T24 == '无'?'field_item3_1':'field_item3'"
                                         @click="form.treatment.T24 = '无'">无
                                    </div>
                                </div>
                            </div>
                            <div v-if="form.treatment.T24 == '艾倍得'">
                                <div class="field_item">
                                    <div class="field_title">
                                        使用天数
                                    </div>
                                    <div>
                                        <Cell is-link :title="form.treatment.T25"
                                              @click="T25Show=true"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        起始剂量（IU）
                                    </div>
                                    <div>
                                        <Field v-model="form.treatment.T26" type="number"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        目前剂量（IU）
                                    </div>
                                    <div>
                                        <Field v-model="form.treatment.T27" type="number"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div v-if="form.treatment.T09.includes('GLP-1RA')">
                            <div class="title_sub">
                                GLP-1RA
                            </div>
                            <div class="field_item" style="display: flex">
                                <div style="width: 100%;margin: 0 auto" v-model="form.treatment.T28">
                                    <div :class="form.treatment.T28 == '利时敏'?'field_item1_1':'field_item1'"
                                         @click="form.treatment.T28 = '利时敏'">利时敏
                                    </div>
                                    <div :class="form.treatment.T28 == '其他GLP-1'?'field_item2_1':'field_item2'"
                                         @click="form.treatment.T28 = '其他GLP-1'">其他GLP-1
                                    </div>
                                    <div :class="form.treatment.T28 == '无'?'field_item3_1':'field_item3'"
                                         @click="form.treatment.T28 = '无'">无
                                    </div>
                                </div>
                            </div>
                            <div v-if="form.treatment.T28 == '利时敏'">
                                <div class="field_item">
                                    <div class="field_title">
                                        使用天数
                                    </div>
                                    <div>
                                        <Cell is-link :title="form.treatment.T29"
                                              @click="T29Show=true"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        起始注射剂量
                                    </div>
                                    <div>
                                        <Cell is-link :title="form.treatment.T30"
                                              @click="T30Show=true"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        目前注射剂量
                                    </div>
                                    <div>
                                        <Cell is-link :title="form.treatment.T31"
                                              @click="T31Show=true"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div v-if="form.treatment.T09.includes('胰岛素（泵）')">
                            <div class="title_sub">
                                胰岛素（泵）
                            </div>
                            <div class="field_item" style="display: flex">
                                <div style="width: 100%;margin: 0 auto" v-model="form.treatment.T32">
                                    <div :class="form.treatment.T32 == '艾倍得'?'field_item1_1':'field_item1'"
                                         @click="form.treatment.T32 = '艾倍得'">艾倍得
                                    </div>
                                    <div :class="form.treatment.T32 == '其他胰岛素'?'field_item2_1':'field_item2'"
                                         @click="form.treatment.T32 = '其他胰岛素'">其他胰岛素
                                    </div>
                                    <div :class="form.treatment.T32 == '无'?'field_item3_1':'field_item3'"
                                         @click="form.treatment.T32 = '无'">无
                                    </div>
                                </div>
                            </div>
                            <div v-if="form.treatment.T32 == '艾倍得'">
                                <div class="field_item">
                                    <div class="field_title">
                                        使用天数
                                    </div>
                                    <div>
                                        <Cell is-link :title="form.treatment.T33"
                                              @click="T33Show=true"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        起始剂量（IU）
                                    </div>
                                    <div>
                                        <Field v-model="form.treatment.T34" type="number"/>
                                    </div>
                                </div>
                                <div class="field_item">
                                    <div class="field_title">
                                        目前剂量（IU）
                                    </div>
                                    <div>
                                        <Field v-model="form.treatment.T35" type="number"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <Overlay :show="T09Show">
                            <CheckboxList2 :fullList="T09Options" :checked="form.treatment.T09"
                                          @confirm="T09Confirm" @cancel="T09Show = false"/>
                        </Overlay>
                        <Overlay :show="T18Show">
                            <RadioList :fullList="T18Options" :checked="form.treatment.T18"
                                       @confirm="T18Confirm"
                                       @cancel="T18Show=false"/>
                        </Overlay>
                        <Overlay :show="T20Show">
                            <RadioList :fullList="T20Options" :checked="form.treatment.T20"
                                       @confirm="T20Confirm"
                                       @cancel="T20Show=false"/>
                        </Overlay>
                        <Overlay :show="T25Show">
                            <RadioList :fullList="T25Options" :checked="form.treatment.T25"
                                       @confirm="T25Confirm"
                                       @cancel="T25Show=false"/>
                        </Overlay>
                        <Overlay :show="T29Show">
                            <RadioList :fullList="T29Options" :checked="form.treatment.T29"
                                       @confirm="T29Confirm"
                                       @cancel="T29Show=false"/>
                        </Overlay>
                        <Overlay :show="T30Show">
                            <RadioList :fullList="T30Options" :checked="form.treatment.T30"
                                       @confirm="T30Confirm"
                                       @cancel="T30Show=false"/>
                        </Overlay>
                        <Overlay :show="T31Show">
                            <RadioList :fullList="T31Options" :checked="form.treatment.T31"
                                       @confirm="T31Confirm"
                                       @cancel="T31Show=false"/>
                        </Overlay>
                        <Overlay :show="T33Show">
                            <RadioList :fullList="T33Options" :checked="form.treatment.T33"
                                       @confirm="T33Confirm"
                                       @cancel="T33Show=false"/>
                        </Overlay>
                    </div>
                    <!--治疗信息-->
                </Tab>
            </div>
        </Tabs>
        <!--保存按钮-->
        <div class="submit">
            <div class="submit_btn" @click="save">
                保存
            </div>
        </div>
        <div class="submit_btn2" @click="submit">
            提交
        </div>
        <div style="margin-top: 20px">
            <img :src="cloud_img" style="width: 100%"/>
        </div>
    </div>
</template>

<script>
    import {Field, Cell, Popup, Picker, Toast, Overlay, Checkbox, CheckboxGroup, CellGroup, Tab, Tabs} from 'vant';
    import cloud_img from '@assets/image/cloud.svg'
    import RadioList from "@components/snfRadioList/index";
    import CheckboxList from "@components/snfCheckboxList/index";
    import RadioLis1 from "@components/snfRadioList/index1";
    import CheckboxList1 from "@components/snfCheckboxList/index1";
    import CheckboxList2 from "@components/snfCheckboxList/index2";

    const B02Options = ['<30岁','30≤岁<40','40≤岁<50','50≤岁<60','≥60']
    const genderOptions = ['男', '女']
    const locationOptions = ['病房', '门诊']
    const diseaseyearOptions = ['新诊断', '<5年', '5≤年<10年', '10≤年<15年', '≥15年']
    const diseaseHistoryOptions = ['高血压', '血脂异常', '冠心病', '脑卒中', '肾功能异常', '肝功能异常', '糖尿病神经病变', '糖尿病视网膜病变', '其他', '无']
    const currentStatusOptions = ['急性发作', '既往史']
    const acuteplanOptions = ['PCI', '非PCI']
    const ecgOptions = ['ST抬高', 'ST压低', 'T波倒置', '病理性Q波', '无明显变化']
    const lastplanOptions = ['新诊断未用药', 'OADs', '基础胰岛素', '餐时胰岛素', '胰岛素（泵）', '预混胰岛素', 'GLP-1RA']
    const currentplanOptions = ['来得时®+OAD', '来得时®基础追加', '来得时®基础餐时', '来得时®短期强化']
    const lantus_recommand_timeOptions = ['<1', '1-3', '3-6', '6-12', '≥12']
    const C16Options = ['≤5.6', '≤6.1', '≤7.0', '≤8.0']
    const C19Options = ['≤7.8', '≤10.0', '≤11.1']
    const T09Options = ['新诊断未用药', 'OADs', '基础胰岛素', '餐时胰岛素', '胰岛素（泵）', 'GLP-1RA']
    const T18Options = ['1', '2', '3', '4', '5']
    const T20Options = ['≤1周', '≤2周', '≤3周', '≤4周']
    const T25Options = ['≤1周', '≤2周', '≤3周', '≤4周']
    const T29Options = ['≤1周', '≤2周', '≤3周', '≤4周']
    const T30Options = ['10ug', '20ug']
    const T31Options = ['10ug', '20ug']
    const T33Options = ['≤1周', '≤2周', '≤3周', '≤4周']
    export default {
        name: "add",
        props: {
            scheduleId: String,
            tabActive: Number
        },
        components: {
            CheckboxList,
            RadioList,
            Field,
            Cell,
            Popup,
            Picker,
            Toast,
            Overlay,
            Checkbox,
            CheckboxGroup,
            CellGroup,
            RadioLis1,
            CheckboxList1,
            Tab,
            Tabs,
            CheckboxList2
        },
        data() {
            return {
                active: '',
                activeStep: '',
                form: {
                    finish: false,
                    callPlanId: this.scheduleId,
                    prodName: '来得时',
                    prodId: 'LANTUS',
                    tabBasic: {
                        B02:'',
                        B03: '',
                        B01: '',
                        B06: '',
                        C15: []

                    },
                    tabDisease: {
                        T09: [],
                        B04: '',
                        B07: '',
                        B05: '',
                        D01: '',
                        D02: '',
                        D03: '',
                        D43: '',
                        D44: ''
                    },
                    tabComplication: {
                        C16: '',
                        C17: '',
                        C18: '',
                        C19: '',
                        C20: '',
                        C21: ''
                    },
                    treatment: {
                        T09: [],
                        T18: '',
                        T20: '',
                        T21: '',
                        T22: '',
                        T23: '',
                        T24: '',
                        T25: '',
                        T26: '',
                        T27: '',
                        T28: '',
                        T29: '',
                        T30: '',
                        T31: '',
                        T32: '',
                        T33: '',
                        T34: '',
                        T35: ''
                    }
                },
                B02Show: false,
                T33Show: false,
                T31Show: false,
                T30Show: false,
                T29Show: false,
                T25Show: false,
                T20Show: false,
                T18Show: false,
                T09Show: false,
                C19Show: false,
                C16Show: false,
                genderShow: false,
                locationShow: false,
                diseaseyearShow: false,
                diseaseHistoryShow: false,
                currentStatusShow: false,
                acuteplanShow: false,
                ecgShow: false,
                lastplanShow: false,
                currentplanShow: false,
                lantus_recommand_timeShow: false,
                genderOptions: genderOptions,
                locationOptions: locationOptions,
                diseaseyearOptions: diseaseyearOptions,
                diseaseHistoryOptions: diseaseHistoryOptions,
                currentStatusOptions: currentStatusOptions,
                acuteplanOptions: acuteplanOptions,
                ecgOptions: ecgOptions,
                lastplanOptions: lastplanOptions,
                C16Options: C16Options,
                C19Options: C19Options,
                T09Options: T09Options,
                T18Options: T18Options,
                T20Options: T20Options,
                T25Options: T25Options,
                T29Options: T29Options,
                T30Options: T30Options,
                T31Options: T31Options,
                T33Options: T33Options,
                B02Options: B02Options,
                currentplanOptions: currentplanOptions,
                lantus_recommand_timeOptions: lantus_recommand_timeOptions,
                cloud_img: cloud_img,
                capsule: {
                    value: '',
                    flag1: false,
                    flag2: false
                }
            }
        },
        methods: {
            C20Change() {
                if (this.form.tabComplication.C20) {
                    if (this.form.tabComplication.C19) {
                        var s = parseFloat(this.form.tabComplication.C19.substr(1))
                        if (this.form.tabComplication.C20 > s) {
                            this.form.tabComplication.C21 = '不达标'
                        } else {
                            this.form.tabComplication.C21 = '达标'
                        }
                    } else {
                        this.form.tabComplication.C21 = ' '
                    }
                } else {
                    this.form.tabComplication.C21 = ' '
                }
            },
            C17Change() {
                if (this.form.tabComplication.C17) {
                    if (this.form.tabComplication.C16) {
                        var s = parseFloat(this.form.tabComplication.C16.substr(1))
                        if (this.form.tabComplication.C17 > s) {
                            this.form.tabComplication.C18 = '不达标'
                        } else {
                            this.form.tabComplication.C18 = '达标'
                        }
                    } else {
                        this.form.tabComplication.C18 = ' '
                    }
                } else {
                    this.form.tabComplication.C18 = ' '
                }
            },
            B04Change() {
                if (this.form.tabDisease.B04) {
                    if (this.form.tabDisease.B07) {
                        let number = this.form.tabDisease.B04 / (this.form.tabDisease.B07/100)/(this.form.tabDisease.B07/100)
                        this.form.tabDisease.B05 = number.toFixed(2)
                    } else {
                        this.form.tabDisease.B05 = ' '
                    }
                } else {
                    this.form.tabDisease.B05 = ' '
                }

            },
            B07Change() {
                if (this.form.tabDisease.B07) {
                    if (this.form.tabDisease.B07) {
                        let number = this.form.tabDisease.B04 / (this.form.tabDisease.B07/100)/(this.form.tabDisease.B07/100)
                        this.form.tabDisease.B05 = number.toFixed(2)
                    } else {
                        this.form.tabDisease.B05 = ' '
                    }
                } else {
                    this.form.tabDisease.B05 = ' '
                }

            },
            capsule1(e) {
                this.form.tabDisease.D44 = e.target.innerHTML
            },
            capsule2(e) {
                this.form.tabDisease.D44 = e.target.innerHTML
            },
            T33Confirm(value, index) {
                this.form.treatment.T33 = value
                this.T33Show = false
            },
            T31Confirm(value, index) {
                this.form.treatment.T31 = value
                this.T31Show = false
            },
            T30Confirm(value, index) {
                this.form.treatment.T30 = value
                this.T30Show = false
            },
            T29Confirm(value, index) {
                this.form.treatment.T29 = value
                this.T29Show = false
            },
            T25Confirm(value, index) {
                this.form.treatment.T25 = value
                this.T25Show = false
            },
            T20Confirm(value, index) {
                this.form.treatment.T20 = value
                this.T20Show = false
            },
            T18Confirm(value, index) {
                this.form.treatment.T18 = value
                this.T18Show = false
            },
            T09Confirm(value, index) {
                this.form.treatment.T09 = value
                this.T09Show = false
            },
            C19Confirm(value, index) {
                this.form.tabComplication.C19 = value
                this.C19Show = false
                if (this.form.tabComplication.C19) {
                    if (this.form.tabComplication.C20) {
                        var s = parseFloat(this.form.tabComplication.C19.substr(1))
                        if (this.form.tabComplication.C20 > s) {
                            this.form.tabComplication.C21 = '不达标'
                        } else {
                            this.form.tabComplication.C21 = '达标'
                        }
                    } else {
                        this.form.tabComplication.C21 = ' '
                    }
                } else {
                    this.form.tabComplication.C21 = ' '
                }
            },
            C16Confirm(value, index) {
                this.form.tabComplication.C16 = value
                this.C16Show = false
                if (this.form.tabComplication.C16) {
                    if (this.form.tabComplication.C17) {
                        var s = parseFloat(this.form.tabComplication.C16.substr(1))
                        if (this.form.tabComplication.C17 > s) {
                            this.form.tabComplication.C18 = '不达标'
                        } else {
                            this.form.tabComplication.C18 = '达标'
                        }
                    } else {
                        this.form.tabComplication.C18 = ' '
                    }
                } else {
                    this.form.tabComplication.C18 = ' '
                }
            },
            currentplanConfirm(value, index) {
                this.form.treatment.T05 = value
                this.currentplanShow = false
            },
            lastplanConfirm(value, index) {
                this.form.tabDisease.T09 = value
                this.lastplanShow = false
            },
            ecgConfirm(value, index) {
                this.form.tabComplication.C08 = value
                this.ecgShow = false
            },
            diseaseHistoryconfirm(value, index) {
                this.form.tabBasic.C15 = value
                this.diseaseHistoryShow = false
            },
            onScroll(e) {
                let scrollItems = document.querySelectorAll(".privilege-wrap");
                for (let i = scrollItems.length - 1; i >= 0; i--) {
                    // 判断滚动条滚动距离是否大于当前滚动项可滚动距离
                    let judge =
                        e.target.scrollTop >=
                        scrollItems[i].offsetTop - scrollItems[0].offsetTop;
                    if (judge) {
                        this.activeStep = i;
                        this.active = this.activeStep
                        break;
                    }
                }
            },
            privilegeHeadClick(anchor) {
                this.$nextTick(() => {
                    document.querySelector(`#${anchor}`).scrollIntoView({
                        behavior: "smooth", // 平滑过渡
                        block: "start" // 上边框与视窗顶部平齐。默认值
                    });
                });
            },
            lantus_recommand_timeConfirm(value, index) {
                this.form.treatment.T08 = value
                this.lantus_recommand_timeShow = false
            },
            acuteplanConfirm(value, index) {
                this.form.tabComplication.C09 = value
                this.acuteplanShow = false
            },
            currentStatusConfirm(value, index) {
                this.form.tabComplication.C07 = value
                this.currentStatusShow = false
            },
            diseaseyearConfirm(value, index) {
                this.form.tabBasic.B06 = value
                this.diseaseyearShow = false
            },
            B02Confirm(value, index) {
                this.form.tabBasic.B02 = value
                this.B02Show = false
            },
            genderConfirm(value, index) {
                this.form.tabBasic.B03 = value
                this.genderShow = false
            },
            locationConfirm(value, index) {
                this.form.tabBasic.B01 = value
                this.locationShow = false
            },
            currentplantoggle(index) {
                this.$refs.currentplancheckboxes[index].toggle();
            },
            lastplantoggle(index) {
                this.$refs.lastplancheckboxes[index].toggle();
            },
            ecgToggle(index) {
                this.$refs.ecgcheckboxes[index].toggle();
            },
            toggle(index) {
                this.$refs.checkboxes[index].toggle();
            },
            saveCheck() {

                if (!this.form.tabBasic.B03) {
                    alert("请选择性别！")
                    return false
                }
                if (!this.form.tabBasic.B01) {
                    alert("请选择地点！")
                    return false
                }
                if(!this.form.tabBasic.B02){
                    alert("请选择年龄！")
                    return false
                }
                if (!this.form.tabBasic.B06) {
                    alert("请选择病程！")
                    return false
                }
                if (this.form.tabBasic.C15.length < 1) {
                    alert("请选择合并症！")
                    return false;
                }

                if (this.form.tabDisease.T09.length < 1) {
                    alert("请选择上次治疗方案！")
                    return false
                }
                if (!this.form.tabDisease.B04) {
                    alert("请输入体重！")
                    return false
                }
                if (!this.form.tabDisease.B07) {
                    alert("请输入身高！")
                    return false
                }
                if (!this.form.tabDisease.B05) {
                    alert("请输入BMI！")
                    return false
                }
                // if(!this.form.tabDisease.D03){
                //     alert("请输入糖化血红蛋白！")
                //     return false
                // }
                // if(!this.form.tabDisease.D01){
                //     alert("请输入空腹血糖！")
                //     return false
                // }
                // if(!this.form.tabDisease.D02){
                //     alert("请输入餐后血糖！")
                //     return false
                // }
                // if(!this.form.tabDisease.D43){
                //     alert("请输入空腹C肽！")
                //     return false
                // }
                // if(!this.form.tabDisease.D44){
                //     alert("请选择空腹C肽单位！")
                //     return false
                // }
                if (!this.form.tabComplication.C16) {
                    alert("请选择血糖目标！")
                    return false
                }
                if (!this.form.tabComplication.C17) {
                    alert("请输入当前血糖！")
                    return false
                }
                if (!this.form.tabComplication.C18) {
                    alert("请输入是否达标！")
                    return false
                }
                if (!this.form.tabComplication.C19) {
                    alert("请选择血糖目标！")
                    return false
                }
                if (!this.form.tabComplication.C20) {
                    alert("请输入当前血糖！")
                    return false
                }
                if (!this.form.tabComplication.C21) {
                    alert("请输入是否达标！")
                    return false
                }
                if (this.form.treatment.T09.length < 1) {
                    alert("请选择选择方案！")
                    return false
                }
                if (this.form.treatment.T09.includes('OADs') && this.form.treatment.T09.length == 1) {
                    alert("请至少选择一种胰岛素作为本次治疗方案!")
                    return false
                }
                if(this.form.treatment.T09.includes("OADs") ){
                    if (!this.form.treatment.T18) {
                        alert("请选择口服药种数！")
                        return false
                    }
                }
                // if(!this.form.treatment.T23){
                //     alert("请选择基础胰岛素！1")
                //     return false
                // }
                if (this.form.treatment.T23 == '来得时') {
                    if (!this.form.treatment.T20) {
                        alert("请选择使用天数！")
                        return false
                    }
                    if (!this.form.treatment.T21) {
                        alert("请输入起始剂量！")
                        return false
                    }
                    if (!this.form.treatment.T22) {
                        alert("请输入目前剂量！")
                        return false
                    }
                }
                // if(!this.form.treatment.T24){
                //     alert("请选择基础胰岛素！2")
                //     return false
                // }
                if (this.form.treatment.T24 == '艾倍得') {
                    if (!this.form.treatment.T25) {
                        alert("请选择使用天数！")
                        return false
                    }
                    if (!this.form.treatment.T26) {
                        alert("请输入起始剂量！")
                        return false
                    }
                    if (!this.form.treatment.T27) {
                        alert("请输入目前剂量！")
                        return false
                    }
                }
                // if(!this.form.treatment.T28){
                //     alert("请选择基础胰岛素！3")
                //     return false
                // }
                if (this.form.treatment.T28 == '利时敏') {
                    if (!this.form.treatment.T29) {
                        alert("请选择使用天数！")
                        return false
                    }
                    if (!this.form.treatment.T30) {
                        alert("请选择起始注射剂量！")
                        return false
                    }
                    if (!this.form.treatment.T31) {
                        alert("请选择目前注射剂量！")
                        return false
                    }
                }
                // if(!this.form.treatment.T32){
                //     alert("请选择基础胰岛素！4")
                //     return false
                // }
                if (this.form.treatment.T32 == '艾倍得') {
                    if (!this.form.treatment.T33) {
                        alert("请选择使用天数！")
                        return false
                    }
                    if (!this.form.treatment.T34) {
                        alert("请输入起始剂量！")
                        return false
                    }
                    if (!this.form.treatment.T35) {
                        alert("请输入目前剂量！")
                        return false
                    }
                }
                return true
            },
            save() {
                this.form.finish = false
                this.$emit('save', Object.assign({}, this.form))
                this.$nextTick(() => {
                    document.querySelector(`#cc`).scrollIntoView({
                        block: "start" // 上边框与视窗顶部平齐。默认值
                    });
                });
                this.form = {
                    finish: false,
                    callPlanId: this.scheduleId,
                    prodName: '来得时',
                    prodId: 'LANTUS',
                    tabBasic: {
                        B02: '',
                        B03: '',
                        B01: '',
                        B06: '',
                        C15: []

                    },
                    tabDisease: {
                        T09: [],
                        B04: '',
                        B07: '',
                        B05: '',
                        D01: '',
                        D02: '',
                        D03: '',
                        D43: '',
                        D44: ''
                    },
                    tabComplication: {
                        C16: '',
                        C17: '',
                        C18: '',
                        C19: '',
                        C20: '',
                        C21: ''
                    },
                    treatment: {
                        T09: [],
                        T18: '',
                        T20: '',
                        T21: '',
                        T22: '',
                        T23: '',
                        T24: '',
                        T25: '',
                        T26: '',
                        T27: '',
                        T28: '',
                        T29: '',
                        T30: '',
                        T31: '',
                        T32: '',
                        T33: '',
                        T34: '',
                        T35: ''

                    }
                }
                this.$emit('hide')
            },
            submit() {
                this.form.finish = this.saveCheck()
                if (this.form.finish) {
                    this.$emit('save', Object.assign({}, this.form))
                    this.$emit('hide')
                } else {
                    return
                }
                this.$nextTick(() => {
                    document.querySelector(`#cc`).scrollIntoView({
                        block: "start" // 上边框与视窗顶部平齐。默认值
                    });
                });
                this.form = {
                    finish: false,
                    callPlanId: this.scheduleId,
                    prodName: '来得时',
                    prodId: 'LANTUS',
                    tabBasic: {
                        B02: '',
                        B03: '',
                        B01: '',
                        B06: '',
                        C15: []

                    },
                    tabDisease: {
                        T09: [],
                        B04: '',
                        B07: '',
                        B05: '',
                        D01: '',
                        D02: '',
                        D03: '',
                        D43: '',
                        D44: ''
                    },
                    tabComplication: {
                        C16: '',
                        C17: '',
                        C18: '',
                        C19: '',
                        C20: '',
                        C21: ''
                    },
                    treatment: {
                        T09: [],
                        T18: '',
                        T20: '',
                        T21: '',
                        T22: '',
                        T23: '',
                        T24: '',
                        T25: '',
                        T26: '',
                        T27: '',
                        T28: '',
                        T29: '',
                        T30: '',
                        T31: '',
                        T32: '',
                        T33: '',
                        T34: '',
                        T35: ''
                    }
                }
            }
        },
        mounted() {
        },
        created() {
            if(!this.form.tabDisease.D44){
                this.form.tabDisease.D44 = '(ug/ml)'
            }
        },
        watch: {
            tabActive(newval, oldval) {
                this.activeStep = newval
            },
            'form.treatment.T09': {
                handler(newval, oldval) {
                    if (!newval.includes('OADs')) {
                        this.form.treatment.T18 = ''
                    }
                    if (!newval.includes('基础胰岛素')) {
                        this.form.treatment.T23 = ''
                        this.form.treatment.T20 = ''
                        this.form.treatment.T21 = ''
                        this.form.treatment.T22 = ''
                    } else {
                        this.form.treatment.T23 = '来得时'
                    }
                    if (!newval.includes('餐时胰岛素')) {
                        this.form.treatment.T24 = ''
                        this.form.treatment.T25 = ''
                        this.form.treatment.T26 = ''
                        this.form.treatment.T27 = ''
                    } else {
                        this.form.treatment.T24 = '艾倍得'
                    }
                    if (!newval.includes('GLP-1RA')) {
                        this.form.treatment.T28 = ''
                        this.form.treatment.T29 = ''
                        this.form.treatment.T30 = ''
                        this.form.treatment.T31 = ''
                    } else {
                        this.form.treatment.T28 = '利时敏'
                    }
                    if (!newval.includes('胰岛素（泵）')) {
                        this.form.treatment.T32 = ''
                        this.form.treatment.T33 = ''
                        this.form.treatment.T34 = ''
                        this.form.treatment.T35 = ''
                    } else {
                        this.form.treatment.T32 = '艾倍得'
                    }
                },
                deep: true,
                immediate: true
            },
            'form.treatment.T23': {
                handler(newval, oldval) {
                    if (newval != '来得时') {
                        this.form.treatment.T20 = ''
                        this.form.treatment.T21 = ''
                        this.form.treatment.T22 = ''
                    }
                },
                deep: true,
                immediate: true
            },
            'form.treatment.T24': {
                handler(newval, oldval) {
                    if (newval != '艾倍得') {
                        this.form.treatment.T25 = ''
                        this.form.treatment.T26 = ''
                        this.form.treatment.T27 = ''
                    }
                },
                deep: true,
                immediate: true
            },
            'form.treatment.T28': {
                handler(newval, oldval) {
                    if (newval != '利时敏') {
                        this.form.treatment.T29 = ''
                        this.form.treatment.T30 = ''
                        this.form.treatment.T31 = ''
                    }
                },
                deep: true,
                immediate: true
            },
            'form.treatment.T32': {
                handler(newval, oldval) {
                    if (newval != '艾倍得') {
                        this.form.treatment.T33 = ''
                        this.form.treatment.T34 = ''
                        this.form.treatment.T35 = ''
                    }
                },
                deep: true,
                immediate: true
            },
            'form.tabBasic.B06': {
                handler(newval, oldval) {
                    if (newval == "新诊断") {
                        this.form.tabDisease.T09 = ["新诊断未用药"]
                    }
                },
                deep: true,
                immediate: true
            }
        }
    }
</script>

<style scoped>
    .wrapper {
        padding: 20px;
        padding-top: 10px;
        overflow: initial;
    }

    .title {
        display: flex;
        flex-direction: row;
        align-items: center;
        /*margin-bottom: 10px;*/
    }

    .title_block {
        background: #ACB318;
        width: 4px;
        height: 20px;
    }

    .title_text {
        font-family: PingFangSC-Semibold;
        font-size: 16px;
        color: #333333;
        letter-spacing: 0.3px;
        text-align: justify;
        line-height: 24px;
        margin-left: 12px;
    }

    .field_title {
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0.22px;
        text-align: justify;
        line-height: 16px;
    }

    .field_item {
        margin-top: 10px;
    }

    .submit {
        width: 100%;
        height: 48px;
        display: flex;
        justify-content: center;
        margin-top: 50px;
        margin-bottom: 20px;
    }

    .submit_btn {
        width: 90%;
        height: 48px;
        background: #ACB318;
        border-radius: 2px;
        border-radius: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
    }

    .submit_btn2 {
        width: 90%;
        height: 48px;
        background: #454592;
        border-radius: 2px;
        border-radius: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        margin: 0 auto;
    }

    .mt20 {
        margin-top: 20px;
    }

    .title_sub {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #454592;
        letter-spacing: 0.26px;
        text-align: justify;
        margin-top: 20px;
    }

    .van-cell {
        padding: 10px 0px !important;
        border-bottom: 1px solid #ddd;
    }

    .capsule1 {
        width: 63px;
        height: 28px;
        border-bottom: 1px solid #454592;
        border-left: 1px solid #454592;
        border-top: 1px solid #454592;
        border-radius: 50px 0 0 50px;
        line-height: 28px;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0.22px;
        text-align: center;
        background: #ffffff;
    }

    .capsule1_1 {
        width: 63px;
        height: 28px;
        border-bottom: 1px solid #454592;
        border-left: 1px solid #454592;
        border-top: 1px solid #454592;
        border-radius: 50px 0 0 50px;
        line-height: 28px;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #454592;
        letter-spacing: 0.22px;
        text-align: center;
        background: #e3e5f5;
    }

    .capsule2 {
        width: 63px;
        height: 28px;
        border-bottom: 1px solid #454592;
        border-right: 1px solid #454592;
        border-top: 1px solid #454592;
        border-radius: 0 50px 50px 0;
        line-height: 28px;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0.22px;
        text-align: center;
        background: #ffffff;
    }

    .capsule2_1 {
        width: 63px;
        height: 28px;
        border-bottom: 1px solid #454592;
        border-right: 1px solid #454592;
        border-top: 1px solid #454592;
        border-radius: 0 50px 50px 0;
        line-height: 28px;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #454592;
        letter-spacing: 0.22px;
        text-align: center;
        background: #e3e5f5;
    }

    .field_item1 {
        width: 33%;
        float: left;
        height: 28px;
        line-height: 28px;
        border-radius: 50px 0 0 50px;
        border-bottom: 1px solid #454592;
        border-left: 1px solid #454592;
        border-top: 1px solid #454592;
        background: #ffffff;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0.22px;
        text-align: center;
    }

    .field_item2 {
        width: 33%;
        float: left;
        height: 28px;
        line-height: 28px;
        border-bottom: 1px solid #454592;
        border-top: 1px solid #454592;
        background: #ffffff;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0.22px;
        text-align: center;
    }

    .field_item3 {
        width: 33%;
        float: left;
        height: 28px;
        line-height: 28px;
        border-radius: 0 50px 50px 0;
        border-bottom: 1px solid #454592;
        border-right: 1px solid #454592;
        border-top: 1px solid #454592;
        background: #ffffff;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0.22px;
        text-align: center;
    }

    .field_item1_1 {
        width: 33%;
        float: left;
        height: 28px;
        line-height: 28px;
        border-radius: 50px 0 0 50px;
        border-bottom: 1px solid #454592;
        border-left: 1px solid #454592;
        border-top: 1px solid #454592;
        background: #e3e5f5;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #454592;
        letter-spacing: 0.22px;
        text-align: center;
    }

    .field_item2_1 {
        width: 33%;
        float: left;
        height: 28px;
        line-height: 28px;
        border-bottom: 1px solid #454592;
        border-top: 1px solid #454592;
        background: #e3e5f5;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #454592;
        letter-spacing: 0.22px;
        text-align: center;
    }

    .field_item3_1 {
        width: 33%;
        float: left;
        height: 28px;
        line-height: 28px;
        border-radius: 0 50px 50px 0;
        border-bottom: 1px solid #454592;
        border-right: 1px solid #454592;
        border-top: 1px solid #454592;
        background: #e3e5f5;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #454592;
        letter-spacing: 0.22px;
        text-align: center;
    }
</style>
<style lang="scss" scoped>
    /deep/ .van-tabs__line {
        width: 33.333% !important;
    }

    /deep/ .van-tab--active {
        color: #454592 !important;
    }
</style>